<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>用户登录</title>
<link href="/theme/default/css.css" type="text/css" rel="stylesheet"/>
<!-- 载入Jquery框架 -->
<script src="/js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="/js/common.js" type="text/javascript"></script>
<script>var fields = Array('username', 'password');</script>
<!-- 载入Jquery消息提示框架 -->
<script src="/js/lhgdialog/lhgdialog.min.js" type="text/javascript"></script>
<!-- 载入Jquery表单插件 -->
<script src="/js/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function() {		
	//设置Ajax属性
	var options = { 
		target: null, 
		type: "post",
		dataType: "json",
		beforeSubmit: checkform,
		url: '{#spUrl c=user a=login}', 
		success: function(json){
			if (json.status == false) {
				$.dialog.tips(json.message); 
				setTimeout("location='{#spUrl c=user a=login}'",500); 
			}
			if (json.status == true) {
				$.dialog.tips(json.message); 
				setTimeout("location='{#spUrl c=main a=index}'",500); 
			}
		},
	};
	$('#form1').ajaxForm(options);
	
	//表单验证函数
	function checkform(){
		//验证用户名
		if ($("#username").val().length < 3 || $("#username").val().length >15 ) {
			$.dialog.tips('请输入您的用户名'); 
			$("#username").focus();
			return false;	
		}
		
		//验证密码
		if ($("#password").val().length < 6 || $("#password").val().length >30 ) {
			$.dialog.tips('请输入您的密码'); 
			$("#password").focus();
			return false;	
		}
		$("#submit").attr("value", "登录中...");
		$("#submit").attr("disabled", true);
		return true;
	}
});
</script>
</head>

<body>
{#include file='header.html'}
<form id="form1" name="form1" method="post" action="{#spUrl c=user a=login}">
    <div class="reg">
        <h2>登录</h2>
        <ul>
        <li><input name="username" type="text" id="username" size="20" class="input" title="请输入用户名" /><label id="username-tip" class="tip" for="username"></label></li>
        <li><input name="password" type="password" id="password" size="20" class="input" title="请输入密码" /><label id="password-tip" class="tip" for="password"></label></li></ul>
        <div class="submit-wrap"><div class="submit-wrap-left"><input name="autologin" type="checkbox" id="autologin" value="1" /> 一周内自动登录</div><div class="submit-wrap-right" align="right"><input type="submit" name="submit" id="submit" value="登录" /></div></div>
    </div>
</form>
</body>
</html>
